package com.yubest.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RoutingDirectConfig {

    @Bean
    public DirectExchange testRoutingDirectExchange() {
        return new DirectExchange("test.routing.direct.exchange");
    }

    @Bean
    public Queue testRoutingDirectQueue1() {
        return new Queue("test.routing.direct.queue1");
    }

    @Bean
    public Queue testRoutingDirectQueue2() {
        return new Queue("test.routing.direct.queue2");
    }

    @Bean
    public Binding testRoutingDirectBinding1() {
        return BindingBuilder.bind(testRoutingDirectQueue1())
                .to(testRoutingDirectExchange()).with("test.routing.direct.key1");
    }

    @Bean
    public Binding testRoutingDirectBinding2() {
        return BindingBuilder.bind(testRoutingDirectQueue1())
                .to(testRoutingDirectExchange()).with("test.routing.direct.key2");
    }

    @Bean
    public Binding testRoutingDirectBinding3() {
        return BindingBuilder.bind(testRoutingDirectQueue2())
                .to(testRoutingDirectExchange()).with("test.routing.direct.key3");
    }

    @Bean
    public Binding testRoutingDirectBinding4() {
        return BindingBuilder.bind(testRoutingDirectQueue2())
                .to(testRoutingDirectExchange()).with("test.routing.direct.key4");
    }
}
